How to demonstrate the method overriding in PHP | PHP programs
We will understand the concept of method overriding using the PHP program. In the method overriding, we can define a method with the same name in the parent and child class.
<?php
class ParentClass
{
public function Method()
{
printf("Parent::Method() called<br>");
}
}
class Child extends ParentClass
{
public function Method()
{
printf("Child::Method() called<br>");
}
}
$ParentObj = new ParentClass();
$ParentObj->Method();
$ChildObj = new Child();
$ChildObj->Method();
?>


